<%--
  Created by IntelliJ IDEA.
  User: PC
  Date: 2017/4/12
  Time: 10:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>实习情况</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../../static/common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../static/common/global.css" media="all">
    <script type="text/javascript" src="../../static/common/layui/layui.js"></script>
    <script src="../../static/common/axios.min.js"></script>
    <script src="../../static/common/vue.min.js"></script>
</head>
<body>
<div class="admin-main" id="Vue" v-cloak>
    <div v-show="show" >
        <blockquote class="layui-elem-quote" id="start_button">
            <a href="javascript:;" class="layui-btn layui-btn-small" @click="add">
                <i class="layui-icon">&#xe608;</i> 实习申请
            </a>
            <a href="javascript:;" class="layui-btn layui-btn-small" @click="addTeacher" id="addTeacher" v-if="studentInfo.advisestate==0||studentInfo.advisestate==3">
                <i class="layui-icon">&#xe608;</i> 申请实习指导老师
            </a>
        </blockquote>
        <fieldset class="layui-elem-field">
            <legend>申请记录</legend>
            <div class="layui-form">
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th>实习单位</th>
                            <th>实习开始时间</th>
                            <th>实习结束时间</th>
                            <th>审核状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="content"></tbody>
                </table>
            </div>
        </fieldset>

        <div class="admin-table-page">
            <div id="paged" class="page">
            </div>
        </div>
    </div>

    <!--编辑-->
    <div v-show="!show" style="display: none">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px">
            <legend>实习信息</legend>
        </fieldset>
        <form id="form" class="layui-form" action="" method="post" style="width: 800px;">
            <div class="layui-form-item">
                <label class="layui-form-label">用人单位</label>
                <div class="layui-input-inline">
                    <select id="org" name="org" lay-filter="org" v-model="internInfo.orgid" lay-search>
                        <option value="0" selected>选择单位</option>
                    </select>
                </div>
                <span id="span">若尚无用人单位记录，则点击<a href="/student/orgInfo?origin='/student/internInfo'&orgId=null&operateType=1" style="text-decoration: underline;color: #0000cc">添加用人单位信息</a><br/>添加单位信息完成后待
                    通过审核再添加实习信息</span>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">实习岗位</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="position" autocomplete="off" v-model="internInfo.position">
                </div>
                <label class="layui-form-label">岗位介绍</label>
                <div class="layui-input-inline">
                    <textarea class="layui-input" name="jobintro" autocomplete="off" v-model="internInfo.jobintro"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">实习内容</label>
                <div class="layui-input-inline">
                    <textarea class="layui-input" name="position" autocomplete="off" v-model="internInfo.jobcontent"></textarea>
                </div>
                <label class="layui-form-label">实习成果</label>
                <div class="layui-input-inline">
                    <textarea class="layui-input" name="outcome" autocomplete="off" v-model="internInfo.outcome"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input class="layui-input"type="text" id="start" name="starttime" v-model="internInfo.start" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD'})">
                </div>
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input class="layui-input"type="text" id="end" name="endtime" v-model="internInfo.end" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD'})">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单位指导老师</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="instructor" autocomplete="off" v-model="internInfo.instructor">
                </div>
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="instructorphone" autocomplete="off" v-model="internInfo.instructorphone">
                </div>
            </div>
            <%--Todo 上传按钮样式切换--%>
            <div class="layui-form-item">
                <label class="layui-form-label">实习办公场地</label>
                <div class="layui-input-block">
                    <input type="file" name="fileUp" id="workEnvironment" class="layui-upload-file disabled_btn">
                    <img id="workpic" style="height: 100px;width: 100px">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">实习协议文件</label>
                <div class="layui-input-block">
                    <input type="file" name="fileUp" id="contract" class="layui-upload-file">
                    <%--<img id="contractPdf" style="height: 100px;width: 100px">--%>
                </div>
            </div>

            <div id="button">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" lay-filter="submit" lay-submit>提交</button>
                        <button type="button" class="layui-btn" lay-filter="saveTemporary" lay-submit>暂存</button>
                        <button type="button" class="layui-btn" @click="reload">返回</button>
                    </div>
                </div>
            </div>

        </form>
    </div>
</div>

<!--模板-->
<script type="text/html" id="tpl">
    {{# layui.each(d.data, function(index, item){ }}
    <tr>
        <td>{{ item.orgInfo.fullname }}</td>

        {{# var time = getYearMonthDate(item.internInfo.start) }}
        <td>{{ time||"-"}}</td>
        {{# var time = getYearMonthDate(item.internInfo.end) }}
        <td>{{ time||"-" }}</td>

        {{#  if(item.internInfo.state == 1||item.internInfo.state == 0||item.internInfo.state == ''){ }}
        <td>未提交申请</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 2){ }}
        <td>待审核</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 3){ }}
        <td>教师审核通过</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 4){ }}
        <td>教师审核不通过</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 5){ }}
        <td>审核通过</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 6){ }}
        <td>行政审核不通过</td>
        {{#  }; }}
        <td>
            <a href="javascript:;" target="_blank" data-id="{{item.internInfo.id}}" data-opt="details" class="layui-btn layui-btn-mini">预览</a>
            {{# if(item.internInfo.state == 1 || item.internInfo.state == 4 || item.internInfo.state == '' || item.internInfo.state == 6){ }}
            <a href="javascript:;" target="_self" data-id="{{item.internInfo.id}}" data-opt="edit" class="layui-btn layui-btn-normal layui-btn-mini">编辑</a>
            {{# };}}
        </td>
    </tr>
    {{# }); }}
</script>
<!--预览模板-->
<script type="text/html" id="detailTpl">
    {{# var item=d.data }}
    <div class="layui-form-item">
        <label class="layui-form-label">实习单位</label>
        <div class="layui-input-inline">
            <input type="text" name="company" autocomplete="off" class="layui-input" value="{{ item.orgInfo.fullname }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习岗位</label>
        <div class="layui-input-inline">
            <input type="text" name="position" autocomplete="off" class="layui-input" value="{{ item.internInfo.position }}" disabled>
        </div>
        <label class="layui-form-label">岗位介绍</label>
        <div class="layui-input-inline">
            <input type="text" name="jobIntro" autocomplete="off" class="layui-input" value="{{ item.internInfo.jobintro }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习内容</label>
        <div class="layui-input-inline">
            <textarea type="text" name="content" autocomplete="off" class="layui-input" value="{{ item.internInfo.jobcontent }}" disabled>{{ item.internInfo.jobcontent }}</textarea>
        </div>
        <label class="layui-form-label">实习成果</label>
        <div class="layui-input-inline">
            <textarea type="text" name="outcome" autocomplete="off" class="layui-input" value="{{ item.internInfo.outcome }}" disabled>{{ item.internInfo.outcome }}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开始时间</label>
        <div class="layui-input-inline">
            <input type="text" name="starttime" autocomplete="off" class="layui-input" value="{{ getYearMonthDate(item.internInfo.start) }}" disabled>
        </div>
        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-inline">
            <input type="text" name="endtime" autocomplete="off" class="layui-input" value="{{ getYearMonthDate(item.internInfo.end) }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习单位指导人员</label>
        <div class="layui-input-inline">
            <input type="text" name="companyGuide" autocomplete="off" class="layui-input" value="{{ item.internInfo.instructor }}" disabled>
        </div>
        <label class="layui-form-label">单位指导联系方式</label>
        <div class="layui-input-inline">
            <input type="text" name="companyGuidePhone" autocomplete="off" class="layui-input" value="{{ item.internInfo.instructorphone }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习办公场地照片</label>
        <div class="layui-input-block">
            <img id="picture" style="height: 100px;width: 100px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            {{# if(item.internInfo.state == 1){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="未提交申请" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 2){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="待审核" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 3){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="审核通过" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 4){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="审核不通过" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 5){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="行政审核通过" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 6){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="行政审核不通过" disabled>
            {{# }; }}
        </div>
        <label class="layui-form-label">审核意见</label>
        <div class="layui-input-inline">
            <textarea type="text" name="suggestion" autocomplete="off" class="layui-input" value="{{ item.internInfo.auditsug }}" readonly="readonly"></textarea>
        </div>
    </div>
</script>
<script>
    var userid = ${sessionScope.currentUser.getId()};
    var company = [];
    layui.use(['form'], function() {
        var $ = layui.jquery,
            form = layui.form();
//        渲染公司企业下拉框
        $.ajax({
            type: "POST",
            url: "/orginfo/findByCondition/",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({state:3}),
            dataType: "json",
            success: function (Response) {
                for (var i = 0; i < Response.data.length; i++) {
                    company[i] = Response.data[i];
                }
                var html = '';
                for (var i = 0; i < company.length;i++) {
                    html += '<option value=' + company[i].id + ' >' + company[i].fullname + '</option>';
                }
                $(org).append(html);
                form.render('select');
//                console.log(company);
            },
            error: function (msg) {
                console.log("失败");
                console.log(msg);
            }
        });
    });
</script>
<script src="../../static/js/student/internInfo.js"></script>
</div>
</body>
</html>